<template>
	<view class="login">
		<view class="login_text">
			JW/AL阿力
		</view>
		<view class="form_data">
			<tm-form
			@submit="submit"
			ref="formData"
			@request="success"
			method="post"> 
				<tm-input name="code" required  v-model="email" placeholder="请输入邮箱号" prefixp-icon='/static/images/zhanghao.png' :adjust-position='true' :maxlength='20'></tm-input>
				<tm-input name="password" required  v-model="password" placeholder="请输入密码" prefixp-icon='/static/images/mima.png' :adjust-position='true' input-type='password' :maxlength='11'></tm-input>
				<view style="text-align: center;">
					<tm-button navtie-type="form"  :disabled='!checked' :theme="!checked?'#9E9E9E':'bg-gradient-orange-accent'">登录</tm-button>
				</view>
			</tm-form>
		</view>
		<view class="register_xy">
			<tm-checkbox v-model="checked" :size='23' round='0' color='orange' model='normal'></tm-checkbox> 我已阅读并同意 <span>《阿力租车登录隐私政策》</span>
		</view>
		<tm-message ref="toast"></tm-message>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				email:'',
				password:'',
				checked:false
			}
		},
		methods: {
			submit(){
				this.dologin()
			},
			// 提示信息
			showMsg(type,text,time=1500){
				this.$refs.toast.show({model:type,mask:false,label:text,wait:time})
			},
			async dologin(){
				const Rres = await  this.$wxRequest({
					url:'/wx/islogin',
					method:'POST',
					data:{
						email:this.email,
						password:this.password,
						openid:uni.getStorageSync('openid')
					}
				})
				if(Rres.data.code == 200){
					uni.setStorageSync('token',Rres.data.token)
					uni.setStorageSync('USERSTATUS',true)
					uni.switchTab({
						url:'/pages/my/my'
					})
				}else{
					this.showMsg('error',Rres.data.msg)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.login{
	.login_text{
		font-size: 60rpx;
		color: #ff8f00;
		font-weight: 700;
		text-align: center;
		height: 200rpx;
		line-height: 200rpx;
	}
	.form_data{
		width: 95%;
		margin: auto;
	}
	.register_xy{
		margin-top: 100rpx;
		font-size: 20rpx;
		color: #5a5a5a;
		text-align: center;
		span{
			color: #ff8f00;
		}
	}
}
</style>
